/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameWork;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author ThanhTri
 */
public class PSRan extends PSystem{
     public PSRan(Image _Image){
         super(_Image);
    }
    
    public void Init (){
        m_MaxParticle =5 ;
        for (int i = 0;i<m_MaxParticle;i++){
		AddParticle();
	}
    }
    public void ResetParticle (Particle _particle){
        _particle.m_X = m_XOrigin + RamdomFloat(0, 20);
        _particle.m_Y = m_YOrigin + RamdomFloat(0, 20);
        
        _particle.m_Vx = RamdomFloat(-20, 20);
        _particle.m_Vy = RamdomFloat(0, 40);
        
        
        _particle.m_LifeTime = RamdomFloat(0.5f, 1.0f);
        _particle.m_Age = 0;
        _particle.m_iLive = true;
    }
    public void DrawScreen (Graphics _g,GameScreen _Screen){
     for (int i = 0; i < m_Particles.size(); i++) {
                Particle p = (Particle) m_Particles.elementAt(i);
                _g.drawRegion(m_Image, 0, 0, 4, 4, Sprite.TRANS_NONE,
                        (int)(p.m_X)- (_Screen.getXView() - _Screen.getWidth()/2),
                        (int)(p.m_Y)- (_Screen.getYView() - _Screen.getHeight()/2),Graphics.TOP|Graphics.LEFT);
            }
    }
}
